#pragma once
#ifndef D3DAPP_H
#define D3DAPP_H


///////////////////////////////////////////////////////////////////////////////////////////////////

class CD3DApp {
public :
    CD3DApp( bool bWindowed, UINT nWidth = 1024, UINT nHeight = 768 ) ;
    virtual ~CD3DApp( ) {} ;

    virtual void    OnKeyboard( UINT nChar, bool bKeyDown, bool bAltDown, void *pUserContext ) {} ;
    
    virtual bool    IsDeviceAcceptable( D3DCAPS9 *pCaps, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void *pUserContext ) { return true ; } ;
    
    virtual HRESULT OnCreateDevice( IDirect3DDevice9 *pd3dDevice, const D3DSURFACE_DESC *pBackBufferSurfaceDesc, void *pUserContext ) { return S_OK ; } ;
    virtual HRESULT OnResetDevice( IDirect3DDevice9 *pd3dDevice, const D3DSURFACE_DESC *pBackBufferSurfaceDesc, void *pUserContext )  { return S_OK ; } ;
    virtual void    OnLostDevice( void *pUserContext ) ;
    virtual void    OnDestroyDevice( void *pUserContext )   {} ;

    virtual void    OnFrameMove( double fTime, float fElapsedTime, void *pUserContext ) {} ;
    virtual void    OnFrameRender( IDirect3DDevice9 *pd3dDevice, double fTime, float fElapsedTime, void *pUserContext ) {} ;

    virtual HRESULT MainLoop( ) { return S_OK ; } ;

protected :
    HINSTANCE           m_hInstance ;
    HWND                m_hWnd ;
    IDirect3D9*         m_pD3D ;
    IDirect3DDevice9*   m_pd3dDevice ;
    D3DEngineState*     m_EngineState ;
};

///////////////////////////////////////////////////////////////////////////////////////////////////

#endif // D3DAPP_H